package com.second;

import com.firstfactory.Person;

public class MakePersonTwo {
    //确保即使添加了新的类，也不需要去修改工厂
    //传入类名
    //返回全限定类名
    public Person makePerson(String className){
        try {
            return (Person) Class.forName("com.firstfactory.Impl."+className).newInstance();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }
}
